package org.shock.ss.sms.commons.utils;

import com.sun.crypto.provider.SunJCE;
import java.io.IOException;
import java.security.Security;
import sun.misc.*;

public class Encryption {
	public Encryption() {
	}

	public static String getEncrypt(String temp) {
		String result = "";
		byte result_byte[] = null;
		byte data[] = null;
		Security.addProvider(new SunJCE());
		data = temp.getBytes();
		result = (new BASE64Encoder()).encode(data);
		return result;
	}

	public static String getDecrypt(String temp) {
		String result = "";
		try {
			byte data[] = (new BASE64Decoder()).decodeBuffer(temp);
			result = new String(data);
		} catch (IOException e) {
			String s = result;
			return s;
		}
		return result;
	}

	public static void main(String args[]) {
		String str_in = "���տ�ODMyMjM5����Ƽ����޹�˾";
		String str_out = getEncrypt(str_in);
		str_in = getDecrypt("ODMyMjM5");
		//System.out.println("str_in=" + str_in);
		//System.out.println("str_out=" + str_out);
	}
}
